package com.lcredu.seckill.config;

import com.lcredu.seckill.pojo.User;

/**
 * @author 黎长容
 * @date 2025-09-13 16:43
 */
//使用threadLocal用来存储拦截器获取的 user 对象
public class UserContext {
    private static ThreadLocal<User> userThreadLocal = new ThreadLocal<>();

    //提供get/set
    public static void setUser(User user) {
        userThreadLocal.set(user);
    }

    public static User getUser() {
        return userThreadLocal.get();
    }
}
